<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .active {
            width: 100px;
            height: 100px;
            background-color: aqua;
        }

        .unActive {
            width: 100px;
            height: 100px;
            background-color: pink;
        }

        .blue {
            color: blue;
        }

        .bold {
            font-weight: bold;
        }

        .italic {
            font-style: italic;
        }
        .red{
            color: red;
        }
        .pink{
            color: hotpink;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 1.动态class的值是一个字符串  -->
        <div v-bind:class="isActive?'active':'unActive'"></div>
        <button v-on:click="isActive=!isActive">改变div颜色</button>

        <!-- 2.动态class的值是个对象 该对象中的属性名是定义的各个类名 属性值是布尔值-->
        <div v-bind:class="myClass">好的</div>
        <div v-bind:class="{red:isColor,bold:isBold,italic:isItalic}">真不错</div>

        <!-- 3.动态的class的值是个数组 数组中的每一项是自己定义的类名 -->
        <div v-bind:class="classArr"> 他强任他强 清风拂山岗</div>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                isActive: false,
                myClass: {
                    blue: true,
                    bold: true,
                    italic: true
                },
                isColor:true,
                isBold:true,
                isItalic:true,
                classArr:['pink','bold']
            }
        })
    </script>
</body>

</html>